﻿using Loogn.OrmLite;
using MicroConfig.NetCore.Server.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MicroConfig.NetCore.Server.Services
{
    public class UserService
    {

        public static UserService Instance = new UserService();

        public User Single(string account, string password)
        {
            using (var db = DB.Open())
            {
                return db.SingleWhere<User>(DictBuilder.Assign("Account", account).Assign("Password", password));
            }
        }

        public int Update(User user)
        {
            user.Id = 1;
            using (var db = DB.Open())
            {
                return db.Update<User>(user);
            }
        }
    }
}
